<?php
/**
 * Created by PhpStorm.
 * Author: 芸签cms www.yunqiancms.com
 * User: sun
 * Date: 2022/6/30
 * Time: 10:54 AM
 */
namespace app\common\models;

class Theme extends BaseModel
{
    public $table = 'yq_theme';
    public $timestamps = true;
    protected $guarded = [''];

    const TYPE_PC = 1;//pc端
    const TYPE_H5 = 2;//手机端
    const TYPE_ALL = 9;//PC/H5

    public static $typeDescMap = [
        self::TYPE_PC=>'pc',
        self::TYPE_H5=>'H5',
        self::TYPE_ALL=>'PC/H5',
    ];

    //给客户单独开发的模版用cus_开头
    //用户自己开发的模版用dev_开头
    //这里限制只能四个字符
    //public static $localPre = ['cus_','dev_'];

    /**
     * 根据theme名称获取数据
     * @param $theme
     * @return Theme
     */
    public static function getByTheme($theme){
        return self::site()->select()
            ->where('theme',$theme)
            ->first();
    }
    public function themeFiles()
    {
        return $this->hasMany(ThemeFile::class, 'theme_id', 'id');
    }

}